#include <iostream>
using namespace std;
class Solution {
public:
    void Swap(char* x,char* y)
    {
        char c = *x;
        *x = *y;
        *y = c;
    }
    void Reverse(string& str)
    {
        int begin = 0,end = str.size()-1;
        while(begin < end)
        {
            Swap(&str[begin],&str[end]);
            begin ++;
            end --;
        }
    }
    string addStrings(string num1, string num2) {
        string str;
        int end1 = num1.size()-1,end2 = num2.size()-1;
        int next = 0;//进位
        while(end1 >= 0 || end2 >= 0)
        {
            int x1 = end1 >= 0 ? num1[end1--] - '0' : 0;
            int x2 = end2 >= 0 ? num2[end2--] - '0' : 0;
            int ret = x1 + x2 + next;
            next = ret / 10;
            ret %= 10;

            str += ret + '0';
            //str.insert(str.begin(),ret +'0');
        }
        Reverse(str);
        return str;
    }
};
int main()
{
    Solution son;
    string s1("123");
    string s2("123");
    cout << son.addStrings(s1,s2) << endl;
    return 0;
}